package com.flurry.sdk;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class jf {
    private static final String b = jf.class.getSimpleName();
    byte[] a;

    /* synthetic */ jf(byte b2) {
        this();
    }

    public static class a implements lg<jf> {
        public final /* synthetic */ void a(OutputStream outputStream, Object obj) throws IOException {
            jf jfVar = (jf) obj;
            if (outputStream != null && jfVar != null) {
                AnonymousClass1 r1 = new DataOutputStream(outputStream) {
                    public final void close() {
                    }
                };
                int i = 0;
                if (jfVar.a != null) {
                    i = jfVar.a.length;
                }
                r1.writeShort(i);
                if (i > 0) {
                    r1.write(jfVar.a);
                }
                r1.flush();
            }
        }

        public final /* synthetic */ Object a(InputStream inputStream) throws IOException {
            if (inputStream == null) {
                return null;
            }
            AnonymousClass2 r1 = new DataInputStream(inputStream) {
                public final void close() {
                }
            };
            jf jfVar = new jf((byte) 0);
            int readUnsignedShort = r1.readUnsignedShort();
            if (readUnsignedShort <= 0) {
                return jfVar;
            }
            byte[] bArr = new byte[readUnsignedShort];
            r1.readFully(bArr);
            jfVar.a = bArr;
            return jfVar;
        }
    }

    private jf() {
    }

    public jf(byte[] bArr) {
        this.a = bArr;
    }

    /* JADX WARNING: Removed duplicated region for block: B:23:0x009d A[Catch:{ IOException -> 0x0102 }] */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x00a5 A[Catch:{ IOException -> 0x0102 }] */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x00ad A[Catch:{ IOException -> 0x0102 }] */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x00ba A[Catch:{ IOException -> 0x0102 }] */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x00eb A[Catch:{ IOException -> 0x0102 }, LOOP:1: B:39:0x00e9->B:40:0x00eb, LOOP_END] */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x01aa A[Catch:{ IOException -> 0x0102 }] */
    /* JADX WARNING: Removed duplicated region for block: B:65:0x01b9 A[Catch:{ IOException -> 0x0102 }] */
    /* JADX WARNING: Removed duplicated region for block: B:69:0x01eb A[Catch:{ IOException -> 0x0102 }] */
    /* JADX WARNING: Removed duplicated region for block: B:82:0x0234  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public jf(com.flurry.sdk.jg r12) throws IOException {
        /*
            r11 = this;
            r10 = -1
            r6 = 1
            r5 = 0
            r11.<init>()
            r3 = 0
            java.io.ByteArrayOutputStream r7 = new java.io.ByteArrayOutputStream     // Catch:{ IOException -> 0x022d, all -> 0x0229 }
            r7.<init>()     // Catch:{ IOException -> 0x022d, all -> 0x0229 }
            java.io.DataOutputStream r4 = new java.io.DataOutputStream     // Catch:{ IOException -> 0x022d, all -> 0x0229 }
            r4.<init>(r7)     // Catch:{ IOException -> 0x022d, all -> 0x0229 }
            r2 = 8
            r4.writeShort(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = r12.a     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
            long r2 = r12.b     // Catch:{ IOException -> 0x0102 }
            r4.writeLong(r2)     // Catch:{ IOException -> 0x0102 }
            long r2 = r12.c     // Catch:{ IOException -> 0x0102 }
            r4.writeLong(r2)     // Catch:{ IOException -> 0x0102 }
            long r2 = r12.d     // Catch:{ IOException -> 0x0102 }
            r4.writeLong(r2)     // Catch:{ IOException -> 0x0102 }
            r2 = 1
            r4.writeBoolean(r2)     // Catch:{ IOException -> 0x0102 }
            r2 = -1
            r4.writeByte(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = r12.f     // Catch:{ IOException -> 0x0102 }
            boolean r2 = android.text.TextUtils.isEmpty(r2)     // Catch:{ IOException -> 0x0102 }
            if (r2 != 0) goto L_0x00fc
            r2 = 1
            r4.writeBoolean(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = r12.f     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
        L_0x0043:
            java.lang.String r2 = r12.g     // Catch:{ IOException -> 0x0102 }
            boolean r2 = android.text.TextUtils.isEmpty(r2)     // Catch:{ IOException -> 0x0102 }
            if (r2 != 0) goto L_0x0111
            r2 = 1
            r4.writeBoolean(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = r12.g     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
        L_0x0054:
            java.util.Map<java.lang.String, java.lang.String> r2 = r12.h     // Catch:{ IOException -> 0x0102 }
            if (r2 != 0) goto L_0x0117
            r2 = 0
            r4.writeShort(r2)     // Catch:{ IOException -> 0x0102 }
        L_0x005c:
            java.util.Map<java.lang.String, java.lang.String> r2 = r12.e     // Catch:{ IOException -> 0x0102 }
            if (r2 != 0) goto L_0x0145
            r2 = 0
            r4.writeShort(r2)     // Catch:{ IOException -> 0x0102 }
        L_0x0064:
            java.lang.String r2 = r12.i     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = r12.j     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
            int r2 = r12.k     // Catch:{ IOException -> 0x0102 }
            r4.writeByte(r2)     // Catch:{ IOException -> 0x0102 }
            int r2 = r12.l     // Catch:{ IOException -> 0x0102 }
            r4.writeByte(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = r12.m     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
            android.location.Location r2 = r12.n     // Catch:{ IOException -> 0x0102 }
            if (r2 != 0) goto L_0x0179
            r2 = r4
        L_0x0082:
            r3 = r2
            r2 = r5
        L_0x0084:
            r3.writeBoolean(r2)     // Catch:{ IOException -> 0x0102 }
            int r2 = r12.o     // Catch:{ IOException -> 0x0102 }
            r4.writeInt(r2)     // Catch:{ IOException -> 0x0102 }
            r2 = -1
            r4.writeByte(r2)     // Catch:{ IOException -> 0x0102 }
            r2 = -1
            r4.writeByte(r2)     // Catch:{ IOException -> 0x0102 }
            byte r2 = r12.p     // Catch:{ IOException -> 0x0102 }
            r4.writeByte(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.Long r2 = r12.q     // Catch:{ IOException -> 0x0102 }
            if (r2 != 0) goto L_0x01aa
            r2 = 0
            r4.writeBoolean(r2)     // Catch:{ IOException -> 0x0102 }
        L_0x00a1:
            java.util.Map<java.lang.String, com.flurry.sdk.jb> r2 = r12.r     // Catch:{ IOException -> 0x0102 }
            if (r2 != 0) goto L_0x01b9
            r2 = 0
            r4.writeShort(r2)     // Catch:{ IOException -> 0x0102 }
        L_0x00a9:
            java.util.List<com.flurry.sdk.jc> r2 = r12.s     // Catch:{ IOException -> 0x0102 }
            if (r2 != 0) goto L_0x01eb
            r2 = 0
            r4.writeShort(r2)     // Catch:{ IOException -> 0x0102 }
        L_0x00b1:
            boolean r2 = r12.t     // Catch:{ IOException -> 0x0102 }
            r4.writeBoolean(r2)     // Catch:{ IOException -> 0x0102 }
            java.util.List<com.flurry.sdk.ja> r8 = r12.v     // Catch:{ IOException -> 0x0102 }
            if (r8 == 0) goto L_0x0234
            java.util.Iterator r9 = r8.iterator()     // Catch:{ IOException -> 0x0102 }
            r3 = r5
            r6 = r5
        L_0x00c0:
            boolean r2 = r9.hasNext()     // Catch:{ IOException -> 0x0102 }
            if (r2 == 0) goto L_0x0231
            java.lang.Object r2 = r9.next()     // Catch:{ IOException -> 0x0102 }
            com.flurry.sdk.ja r2 = (com.flurry.sdk.ja) r2     // Catch:{ IOException -> 0x0102 }
            byte[] r2 = r2.a()     // Catch:{ IOException -> 0x0102 }
            int r2 = r2.length     // Catch:{ IOException -> 0x0102 }
            int r2 = r2 + r6
            r6 = 160000(0x27100, float:2.24208E-40)
            if (r2 <= r6) goto L_0x020a
            r2 = 5
            java.lang.String r6 = b     // Catch:{ IOException -> 0x0102 }
            java.lang.String r9 = "Error Log size exceeded. No more event details logged."
            com.flurry.sdk.km.a((int) r2, (java.lang.String) r6, (java.lang.String) r9)     // Catch:{ IOException -> 0x0102 }
            r6 = r3
        L_0x00e0:
            int r2 = r12.u     // Catch:{ IOException -> 0x0102 }
            r4.writeInt(r2)     // Catch:{ IOException -> 0x0102 }
            r4.writeShort(r6)     // Catch:{ IOException -> 0x0102 }
            r3 = r5
        L_0x00e9:
            if (r3 >= r6) goto L_0x020f
            java.lang.Object r2 = r8.get(r3)     // Catch:{ IOException -> 0x0102 }
            com.flurry.sdk.ja r2 = (com.flurry.sdk.ja) r2     // Catch:{ IOException -> 0x0102 }
            byte[] r2 = r2.a()     // Catch:{ IOException -> 0x0102 }
            r4.write(r2)     // Catch:{ IOException -> 0x0102 }
            int r2 = r3 + 1
            r3 = r2
            goto L_0x00e9
        L_0x00fc:
            r2 = 0
            r4.writeBoolean(r2)     // Catch:{ IOException -> 0x0102 }
            goto L_0x0043
        L_0x0102:
            r2 = move-exception
        L_0x0103:
            r3 = 6
            java.lang.String r5 = b     // Catch:{ all -> 0x010c }
            java.lang.String r6 = ""
            com.flurry.sdk.km.a(r3, r5, r6, r2)     // Catch:{ all -> 0x010c }
            throw r2     // Catch:{ all -> 0x010c }
        L_0x010c:
            r2 = move-exception
        L_0x010d:
            com.flurry.sdk.ly.a((java.io.Closeable) r4)
            throw r2
        L_0x0111:
            r2 = 0
            r4.writeBoolean(r2)     // Catch:{ IOException -> 0x0102 }
            goto L_0x0054
        L_0x0117:
            int r3 = r2.size()     // Catch:{ IOException -> 0x0102 }
            r4.writeShort(r3)     // Catch:{ IOException -> 0x0102 }
            java.util.Set r2 = r2.entrySet()     // Catch:{ IOException -> 0x0102 }
            java.util.Iterator r8 = r2.iterator()     // Catch:{ IOException -> 0x0102 }
        L_0x0126:
            boolean r2 = r8.hasNext()     // Catch:{ IOException -> 0x0102 }
            if (r2 == 0) goto L_0x005c
            java.lang.Object r2 = r8.next()     // Catch:{ IOException -> 0x0102 }
            java.util.Map$Entry r2 = (java.util.Map.Entry) r2     // Catch:{ IOException -> 0x0102 }
            java.lang.Object r3 = r2.getKey()     // Catch:{ IOException -> 0x0102 }
            java.lang.String r3 = (java.lang.String) r3     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r3)     // Catch:{ IOException -> 0x0102 }
            java.lang.Object r2 = r2.getValue()     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = (java.lang.String) r2     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
            goto L_0x0126
        L_0x0145:
            int r3 = r2.size()     // Catch:{ IOException -> 0x0102 }
            r4.writeShort(r3)     // Catch:{ IOException -> 0x0102 }
            java.util.Set r2 = r2.entrySet()     // Catch:{ IOException -> 0x0102 }
            java.util.Iterator r8 = r2.iterator()     // Catch:{ IOException -> 0x0102 }
        L_0x0154:
            boolean r2 = r8.hasNext()     // Catch:{ IOException -> 0x0102 }
            if (r2 == 0) goto L_0x0064
            java.lang.Object r2 = r8.next()     // Catch:{ IOException -> 0x0102 }
            r0 = r2
            java.util.Map$Entry r0 = (java.util.Map.Entry) r0     // Catch:{ IOException -> 0x0102 }
            r3 = r0
            java.lang.Object r2 = r3.getKey()     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = (java.lang.String) r2     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.Object r2 = r3.getValue()     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = (java.lang.String) r2     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
            r2 = 0
            r4.writeByte(r2)     // Catch:{ IOException -> 0x0102 }
            goto L_0x0154
        L_0x0179:
            int r2 = com.flurry.sdk.jp.b()     // Catch:{ IOException -> 0x0102 }
            r3 = 1
            r4.writeBoolean(r3)     // Catch:{ IOException -> 0x0102 }
            android.location.Location r3 = r12.n     // Catch:{ IOException -> 0x0102 }
            double r8 = r3.getLatitude()     // Catch:{ IOException -> 0x0102 }
            double r8 = com.flurry.sdk.ly.a((double) r8, (int) r2)     // Catch:{ IOException -> 0x0102 }
            r4.writeDouble(r8)     // Catch:{ IOException -> 0x0102 }
            android.location.Location r3 = r12.n     // Catch:{ IOException -> 0x0102 }
            double r8 = r3.getLongitude()     // Catch:{ IOException -> 0x0102 }
            double r8 = com.flurry.sdk.ly.a((double) r8, (int) r2)     // Catch:{ IOException -> 0x0102 }
            r4.writeDouble(r8)     // Catch:{ IOException -> 0x0102 }
            android.location.Location r3 = r12.n     // Catch:{ IOException -> 0x0102 }
            float r3 = r3.getAccuracy()     // Catch:{ IOException -> 0x0102 }
            r4.writeFloat(r3)     // Catch:{ IOException -> 0x0102 }
            if (r2 == r10) goto L_0x0237
            r2 = r6
            r3 = r4
            goto L_0x0084
        L_0x01aa:
            r2 = 1
            r4.writeBoolean(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.Long r2 = r12.q     // Catch:{ IOException -> 0x0102 }
            long r2 = r2.longValue()     // Catch:{ IOException -> 0x0102 }
            r4.writeLong(r2)     // Catch:{ IOException -> 0x0102 }
            goto L_0x00a1
        L_0x01b9:
            int r3 = r2.size()     // Catch:{ IOException -> 0x0102 }
            r4.writeShort(r3)     // Catch:{ IOException -> 0x0102 }
            java.util.Set r2 = r2.entrySet()     // Catch:{ IOException -> 0x0102 }
            java.util.Iterator r6 = r2.iterator()     // Catch:{ IOException -> 0x0102 }
        L_0x01c8:
            boolean r2 = r6.hasNext()     // Catch:{ IOException -> 0x0102 }
            if (r2 == 0) goto L_0x00a9
            java.lang.Object r2 = r6.next()     // Catch:{ IOException -> 0x0102 }
            r0 = r2
            java.util.Map$Entry r0 = (java.util.Map.Entry) r0     // Catch:{ IOException -> 0x0102 }
            r3 = r0
            java.lang.Object r2 = r3.getKey()     // Catch:{ IOException -> 0x0102 }
            java.lang.String r2 = (java.lang.String) r2     // Catch:{ IOException -> 0x0102 }
            r4.writeUTF(r2)     // Catch:{ IOException -> 0x0102 }
            java.lang.Object r2 = r3.getValue()     // Catch:{ IOException -> 0x0102 }
            com.flurry.sdk.jb r2 = (com.flurry.sdk.jb) r2     // Catch:{ IOException -> 0x0102 }
            int r2 = r2.a     // Catch:{ IOException -> 0x0102 }
            r4.writeInt(r2)     // Catch:{ IOException -> 0x0102 }
            goto L_0x01c8
        L_0x01eb:
            int r3 = r2.size()     // Catch:{ IOException -> 0x0102 }
            r4.writeShort(r3)     // Catch:{ IOException -> 0x0102 }
            java.util.Iterator r3 = r2.iterator()     // Catch:{ IOException -> 0x0102 }
        L_0x01f6:
            boolean r2 = r3.hasNext()     // Catch:{ IOException -> 0x0102 }
            if (r2 == 0) goto L_0x00b1
            java.lang.Object r2 = r3.next()     // Catch:{ IOException -> 0x0102 }
            com.flurry.sdk.jc r2 = (com.flurry.sdk.jc) r2     // Catch:{ IOException -> 0x0102 }
            byte[] r2 = r2.b()     // Catch:{ IOException -> 0x0102 }
            r4.write(r2)     // Catch:{ IOException -> 0x0102 }
            goto L_0x01f6
        L_0x020a:
            int r3 = r3 + 1
            r6 = r2
            goto L_0x00c0
        L_0x020f:
            r2 = -1
            r4.writeInt(r2)     // Catch:{ IOException -> 0x0102 }
            r2 = 0
            r4.writeShort(r2)     // Catch:{ IOException -> 0x0102 }
            r2 = 0
            r4.writeShort(r2)     // Catch:{ IOException -> 0x0102 }
            r2 = 0
            r4.writeShort(r2)     // Catch:{ IOException -> 0x0102 }
            byte[] r2 = r7.toByteArray()     // Catch:{ IOException -> 0x0102 }
            r11.a = r2     // Catch:{ IOException -> 0x0102 }
            com.flurry.sdk.ly.a((java.io.Closeable) r4)
            return
        L_0x0229:
            r2 = move-exception
            r4 = r3
            goto L_0x010d
        L_0x022d:
            r2 = move-exception
            r4 = r3
            goto L_0x0103
        L_0x0231:
            r6 = r3
            goto L_0x00e0
        L_0x0234:
            r6 = r5
            goto L_0x00e0
        L_0x0237:
            r2 = r4
            goto L_0x0082
        */
        throw new UnsupportedOperationException("Method not decompiled: com.flurry.sdk.jf.<init>(com.flurry.sdk.jg):void");
    }
}
